package objects.cicleItem 
{
	import feathers.controls.Label;
	import flash.geom.Rectangle;
	import starling.display.Button;
	import starling.display.Image;
	import starling.display.Sprite;
	import starling.filters.ColorMatrixFilter;
	import starling.text.TextField;
	import starling.text.TextFieldAutoSize;
	import starling.filters.BlurFilter;
	
	/**
	/**
	 * ...
	 * @author 
	 */
	public class itemInCicle extends Button 
	{
		public var m_coint:int;
		public var m_textY:int;
		public var mt:ColorMatrixFilter;
		public var m_info:TextField;
		public var background:Image;
		public var m_text:TextField;
		public var m_sprite:Sprite;
		public var m_enabled:Boolean;
		public var m_clock:Boolean;
		public function itemInCicle(_coint:int, base:String,_sprite:Sprite) 
		{
			m_sprite = _sprite;
			super(Assets.getSpriteSheet().getTexture(base), "");
			m_text= new TextField(0, 0, "", "MyFontName", 15, 0x000000);
			m_textY = 20;
			m_coint = _coint;
			m_info = new TextField(150, 150, "", "MyFontName", 15, 0x000000);
			m_info.hAlign = "left";
			m_info.vAlign = "top";
			m_sprite.addChild(m_info);
			m_info.visible = false;
			background = new Image(Assets.getTexture("background2"));
			background.alpha = 0.7;
			m_info.addChild(background);
			m_enabled = true;
			var textBounds : Rectangle = new Rectangle(0, 20, this.textBounds.width, this.textBounds.height);
			this.textBounds = textBounds;
		}
		public function addText(_text:String,color:String,size:int,kc:int):void
		{
			var text:TextField = new TextField(500, 500, _text, "MyFontName", size, 0xffffff);
			text.color = uint(color);
			text.hAlign = "left";
			text.vAlign = "top";
			text.y += kc;
			m_text.text += _text;
			m_info.addChild(text);
			
		}
		public function refresh():void
		{
			m_info.removeChildren();
			background.scaleX = 1;
			background.scaleY = 1;
			m_info.addChild(background);
			m_text.text = "";
		}
		public function setScale(x:int,y:int):void
		{
			background.scaleX = (m_text.textBounds.width-x) / background.width;
			background.scaleY = (m_text.textBounds.height-y)  / background.height;
		}
		public function showCoint(_coint:int):void
		{
			this.text = m_coint + "";
			if (m_coint <= 0)
				this.text = "";
			if (m_coint > _coint)
			{
				//this.enabled = false;
				m_enabled = false;
				
				this.fontColor = 0xffffff;
			}
			else
				{
					//this.enabled  = true;
					m_enabled = true;
					this.fontColor = 0xffff66;
				}
			if (m_clock == true)
			{
				this.text ="";
				m_enabled = false;
			}
		}
		
		public function release():void {
			background = null;
			this.removeChildren();
			m_info.removeChildren();
			m_sprite.removeChild(m_info);
			
		}
		
	}

}